package org.csu.mypetstorems.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.csu.mypetstorems.entity.Order;
import org.csu.mypetstorems.entity.PageBean;
import org.csu.mypetstorems.entity.User;
import org.csu.mypetstorems.mapper.UserMapper;
import org.csu.mypetstorems.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("userService")
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public PageBean<User> getUserListWithCondition(Integer pageNum, Integer pageSize, String userId) {
        PageBean<User> pageBean = new PageBean<>();
        PageHelper.startPage(pageNum, pageSize);
        List<User> UserList = userMapper.getUserListWithCondition(userId);
        Page<User> page = (Page<User>) UserList;
        pageBean.setTotal(page.getTotal());
        pageBean.setList(page.getResult());
        return pageBean;
    }
}
